package test.test1;



import java.util.Calendar;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import test.test1.mybatis.pojo.Question;
import test.test1.mybatis.pojo.Player;

/**
 * Hello world!
 *
 */
public class SpringBeanName 
{
    public static void main( String[] args )
    {
    	
//    	springDemo();
    	//springClassDemo();//throw error
    	springClassDemo2();
    }
    
    
    
    private static void springDemo() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanName.xml");
    	Question q = context.getBean("questionname", Question.class);
    	System.out.println(q);
    	System.out.println(q.getPlayer());
    	System.out.println("=======================");
    	Question q2 = context.getBean("qname", Question.class);
    	System.out.println(q2);
    	System.out.println(q2.getPlayer());
    	System.out.println("=======================2222222222");
    	Question q3 = context.getBean("qalias", Question.class);
    	System.out.println(q3);
    	System.out.println(q3.getPlayer());
    }
 
    
    private static void springClassDemo() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanName.xml");
    	context.getBean("testNoEmpty");
    }
    
    private static void springClassDemo2() {
    	ApplicationContext context =
    		    new ClassPathXmlApplicationContext("springBeanName.xml");
    	//context.getBean("testNoEmpty");
    	//Calendar cal = new Calendar();
    	Calendar cal = (Calendar) context.getBean("myCalendar");
    	System.out.println(cal);
    }
}
